using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Printing;

class MyWindow:Form
{
	public  MyWindow()
	{
		Text="Printable Form";
		ForeColor=SystemColors.WindowText;
		BackColor=SystemColors.Window;
		ResizeRedraw=true;
	}
	protected override void OnPaint(PaintEventArgs e)
	{
		base.OnPaint (e);
		DoPage(e.Graphics,ForeColor,ClientSize.Width,ClientSize.Height);

	}
	protected override void OnClick(EventArgs e)
	{
		base.OnClick(e);
		PrintDocument pd=new PrintDocument();
		pd.DocumentName="PD";
		pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
		pd.Print();
		
	}
    
	private void pd_PrintPage(object sender, PrintPageEventArgs e)
	{
	/*	Graphics g=e.Graphics;
		g.DrawString("HelloWorld",Font,Brushes.Black,0,0);		
		SizeF sizeF=g.MeasureString("HelloWorld",Font);
		g.DrawLine(Pens.Black,sizeF.ToPointF(),g.VisibleClipBounds.Size.ToPointF());
	*/
		Graphics g=e.Graphics;
		SizeF sizef=g.VisibleClipBounds.Size;
		DoPage(g,Color.Black,(int)sizef.Width,(int)sizef.Height);
	}
	protected virtual void DoPage(Graphics grfx,Color clr,int cx,int cy)
	{
//		Pen pen=new Pen(clr);
//		g.DrawLine(pen,0,0,cx-1,cy-1);
//		g.DrawLine(pen,cx-1,0,0,cy-1);
	}


}
class FourByFours: MyWindow
{
	public FourByFours()
	{
		Text = "Four by Fours";
	}
	protected override void DoPage(Graphics grfx, Color clr, int cx, int
		cy)
	{
		Pen pen = new Pen(clr);
		Brush brush = new SolidBrush(clr);
		grfx.DrawRectangle(pen, new Rectangle(2, 2, 4, 4));
		grfx.DrawRectangles(pen, new Rectangle[]{new Rectangle(8, 2, 4, 4)});
		grfx.DrawEllipse(pen, new Rectangle(14, 2, 4, 4));
		grfx.FillRectangle(brush, new Rectangle(2, 8, 4, 4));
		grfx.FillRectangles(brush, new Rectangle[]{new Rectangle(8, 8, 4, 4)});
		grfx.FillEllipse(brush, new Rectangle(14, 8, 4, 4));
	}
}

class _Main
{
	static void Main()
	{
		Application.Run(new FourByFours());
	}
}


